local skel = fk.CreateSkill {
  name = "emo__quanyu",
  tags = {Skill.Lord},
}

Fk:loadTranslationTable{
  ["emo__quanyu"] = "权御",
  [":emo__quanyu"] = "主公技，准备阶段，你可以获得一名其他吴势力角色装备区所有牌，再交给其等量张牌。",

  ["#emo__quanyu-choose"] = "权御:获得一名其他吴势力角色装备区所有牌，再交给其等量张牌",
  ["#emo__quanyu-give"] = "权御:交给 %dest %arg 张牌",

  ["$emo__quanyu1"] = "不愧是朕的左臂右膀。",
  ["$emo__quanyu2"] = "得此良将，实谓朕心。",
}

skel:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Start
    and table.find(player.room.alive_players, function (p)
      return p ~= player and p.kingdom == "wu" and #p:getCardIds("e") > 0
    end)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function (p)
      return p ~= player and p.kingdom == "wu" and #p:getCardIds("e") > 0
    end)
    local tos = room:askToChoosePlayers(player, {
      min_num = 1, max_num = 1, targets = targets, skill_name = skel.name,
      prompt = "#emo__quanyu-choose",
    })
    if #tos > 0 then
      event:setCostData(self, {tos = tos})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local cards = to:getCardIds("e")
    room:obtainCard(player, cards, false, fk.ReasonPrey, player, skel.name)
    if player.dead or to.dead or player:isNude() then return end
    cards = room:askToCards(player, {
      min_num = #cards, max_num = #cards, skill_name = skel.name, include_equip = true, cancelable = false,
      prompt = "#emo__quanyu-give::" .. to.id .. ":" .. #cards
    })
    room:obtainCard(to, cards, false, fk.ReasonGive, player, skel.name)
  end,
})

return skel
